// $ANTLR 3.4

	package edu.pku.sei.AMT.resource.amtscript.mopp;


import org.antlr.runtime3_4_0.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

@SuppressWarnings({"all", "warnings", "unchecked"})
public class AmtscriptParser extends AmtscriptANTLRParserBase {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "EXPR", "IDENTIFIER", "KEYFEATURENAME", "LINEBREAK", "URI", "WHITESPACE", "','", "'.'", "':'", "'::'", "';'", "'='", "'for'", "'key'", "'rule'", "'transformation'", "'{'", "'}'"
    };

    public static final int EOF=-1;
    public static final int T__10=10;
    public static final int T__11=11;
    public static final int T__12=12;
    public static final int T__13=13;
    public static final int T__14=14;
    public static final int T__15=15;
    public static final int T__16=16;
    public static final int T__17=17;
    public static final int T__18=18;
    public static final int T__19=19;
    public static final int T__20=20;
    public static final int T__21=21;
    public static final int EXPR=4;
    public static final int IDENTIFIER=5;
    public static final int KEYFEATURENAME=6;
    public static final int LINEBREAK=7;
    public static final int URI=8;
    public static final int WHITESPACE=9;

    // delegates
    public AmtscriptANTLRParserBase[] getDelegates() {
        return new AmtscriptANTLRParserBase[] {};
    }

    // delegators


    public AmtscriptParser(TokenStream input) {
        this(input, new RecognizerSharedState());
    }
    public AmtscriptParser(TokenStream input, RecognizerSharedState state) {
        super(input, state);
        this.state.initializeRuleMemo(27 + 1);
         

    }

    public String[] getTokenNames() { return AmtscriptParser.tokenNames; }
    public String getGrammarFileName() { return "Amtscript.g"; }


    	private edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolverFactory tokenResolverFactory = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTokenResolverFactory();
    	
    	/**
    	 * the index of the last token that was handled by collectHiddenTokens()
    	 */
    	private int lastPosition;
    	
    	/**
    	 * A flag that indicates whether the parser should remember all expected elements.
    	 * This flag is set to true when using the parse for code completion. Otherwise it
    	 * is set to false.
    	 */
    	private boolean rememberExpectedElements = false;
    	
    	private Object parseToIndexTypeObject;
    	private int lastTokenIndex = 0;
    	
    	/**
    	 * A list of expected elements the were collected while parsing the input stream.
    	 * This list is only filled if <code>rememberExpectedElements</code> is set to
    	 * true.
    	 */
    	private java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> expectedElements = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
    	
    	private int mismatchedTokenRecoveryTries = 0;
    	/**
    	 * A helper list to allow a lexer to pass errors to its parser
    	 */
    	protected java.util.List<org.antlr.runtime3_4_0.RecognitionException> lexerExceptions = java.util.Collections.synchronizedList(new java.util.ArrayList<org.antlr.runtime3_4_0.RecognitionException>());
    	
    	/**
    	 * Another helper list to allow a lexer to pass positions of errors to its parser
    	 */
    	protected java.util.List<Integer> lexerExceptionsPosition = java.util.Collections.synchronizedList(new java.util.ArrayList<Integer>());
    	
    	/**
    	 * A stack for incomplete objects. This stack is used filled when the parser is
    	 * used for code completion. Whenever the parser starts to read an object it is
    	 * pushed on the stack. Once the element was parser completely it is popped from
    	 * the stack.
    	 */
    	java.util.List<org.eclipse.emf.ecore.EObject> incompleteObjects = new java.util.ArrayList<org.eclipse.emf.ecore.EObject>();
    	
    	private int stopIncludingHiddenTokens;
    	private int stopExcludingHiddenTokens;
    	private int tokenIndexOfLastCompleteElement;
    	
    	private int expectedElementsIndexOfLastCompleteElement;
    	
    	/**
    	 * The offset indicating the cursor position when the parser is used for code
    	 * completion by calling parseToExpectedElements().
    	 */
    	private int cursorOffset;
    	
    	/**
    	 * The offset of the first hidden token of the last expected element. This offset
    	 * is used to discard expected elements, which are not needed for code completion.
    	 */
    	private int lastStartIncludingHidden;
    	
    	protected void addErrorToResource(final String errorMessage, final int column, final int line, final int startIndex, final int stopIndex) {
    		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
    			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
    				if (resource == null) {
    					// the resource can be null if the parser is used for code completion
    					return true;
    				}
    				resource.addProblem(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptProblem() {
    					public edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemSeverity getSeverity() {
    						return edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemSeverity.ERROR;
    					}
    					public edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemType getType() {
    						return edu.pku.sei.AMT.resource.amtscript.AmtscriptEProblemType.SYNTAX_ERROR;
    					}
    					public String getMessage() {
    						return errorMessage;
    					}
    					public java.util.Collection<edu.pku.sei.AMT.resource.amtscript.IAmtscriptQuickFix> getQuickFixes() {
    						return null;
    					}
    				}, column, line, startIndex, stopIndex);
    				return true;
    			}
    		});
    	}
    	
    	public void addExpectedElement(org.eclipse.emf.ecore.EClass eClass, int[] ids) {
    		if (!this.rememberExpectedElements) {
    			return;
    		}
    		int terminalID = ids[0];
    		int followSetID = ids[1];
    		edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement terminal = edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptFollowSetProvider.TERMINALS[terminalID];
    		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[] containmentFeatures = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[ids.length - 2];
    		for (int i = 2; i < ids.length; i++) {
    			containmentFeatures[i - 2] = edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptFollowSetProvider.LINKS[ids[i]];
    		}
    		edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace containmentTrace = new edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace(eClass, containmentFeatures);
    		org.eclipse.emf.ecore.EObject container = getLastIncompleteElement();
    		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElement = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal(container, terminal, followSetID, containmentTrace);
    		setPosition(expectedElement, input.index());
    		int startIncludingHiddenTokens = expectedElement.getStartIncludingHiddenTokens();
    		if (lastStartIncludingHidden >= 0 && lastStartIncludingHidden < startIncludingHiddenTokens && cursorOffset > startIncludingHiddenTokens) {
    			// clear list of expected elements
    			this.expectedElements.clear();
    			this.expectedElementsIndexOfLastCompleteElement = 0;
    		}
    		lastStartIncludingHidden = startIncludingHiddenTokens;
    		this.expectedElements.add(expectedElement);
    	}
    	
    	protected void collectHiddenTokens(org.eclipse.emf.ecore.EObject element) {
    	}
    	
    	protected void copyLocalizationInfos(final org.eclipse.emf.ecore.EObject source, final org.eclipse.emf.ecore.EObject target) {
    		if (disableLocationMap) {
    			return;
    		}
    		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
    			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
    				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
    				if (locationMap == null) {
    					// the locationMap can be null if the parser is used for code completion
    					return true;
    				}
    				locationMap.setCharStart(target, locationMap.getCharStart(source));
    				locationMap.setCharEnd(target, locationMap.getCharEnd(source));
    				locationMap.setColumn(target, locationMap.getColumn(source));
    				locationMap.setLine(target, locationMap.getLine(source));
    				return true;
    			}
    		});
    	}
    	
    	protected void copyLocalizationInfos(final org.antlr.runtime3_4_0.CommonToken source, final org.eclipse.emf.ecore.EObject target) {
    		if (disableLocationMap) {
    			return;
    		}
    		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
    			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
    				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
    				if (locationMap == null) {
    					// the locationMap can be null if the parser is used for code completion
    					return true;
    				}
    				if (source == null) {
    					return true;
    				}
    				locationMap.setCharStart(target, source.getStartIndex());
    				locationMap.setCharEnd(target, source.getStopIndex());
    				locationMap.setColumn(target, source.getCharPositionInLine());
    				locationMap.setLine(target, source.getLine());
    				return true;
    			}
    		});
    	}
    	
    	/**
    	 * Sets the end character index and the last line for the given object in the
    	 * location map.
    	 */
    	protected void setLocalizationEnd(java.util.Collection<edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>> postParseCommands , final org.eclipse.emf.ecore.EObject object, final int endChar, final int endLine) {
    		if (disableLocationMap) {
    			return;
    		}
    		postParseCommands.add(new edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>() {
    			public boolean execute(edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource resource) {
    				edu.pku.sei.AMT.resource.amtscript.IAmtscriptLocationMap locationMap = resource.getLocationMap();
    				if (locationMap == null) {
    					// the locationMap can be null if the parser is used for code completion
    					return true;
    				}
    				locationMap.setCharEnd(object, endChar);
    				locationMap.setLine(object, endLine);
    				return true;
    			}
    		});
    	}
    	
    	public edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextParser createInstance(java.io.InputStream actualInputStream, String encoding) {
    		try {
    			if (encoding == null) {
    				return new AmtscriptParser(new org.antlr.runtime3_4_0.CommonTokenStream(new AmtscriptLexer(new org.antlr.runtime3_4_0.ANTLRInputStream(actualInputStream))));
    			} else {
    				return new AmtscriptParser(new org.antlr.runtime3_4_0.CommonTokenStream(new AmtscriptLexer(new org.antlr.runtime3_4_0.ANTLRInputStream(actualInputStream, encoding))));
    			}
    		} catch (java.io.IOException e) {
    			new edu.pku.sei.AMT.resource.amtscript.util.AmtscriptRuntimeUtil().logError("Error while creating parser.", e);
    			return null;
    		}
    	}
    	
    	/**
    	 * This default constructor is only used to call createInstance() on it.
    	 */
    	public AmtscriptParser() {
    		super(null);
    	}
    	
    	protected org.eclipse.emf.ecore.EObject doParse() throws org.antlr.runtime3_4_0.RecognitionException {
    		this.lastPosition = 0;
    		// required because the lexer class can not be subclassed
    		((AmtscriptLexer) getTokenStream().getTokenSource()).lexerExceptions = lexerExceptions;
    		((AmtscriptLexer) getTokenStream().getTokenSource()).lexerExceptionsPosition = lexerExceptionsPosition;
    		Object typeObject = getTypeObject();
    		if (typeObject == null) {
    			return start();
    		} else if (typeObject instanceof org.eclipse.emf.ecore.EClass) {
    			org.eclipse.emf.ecore.EClass type = (org.eclipse.emf.ecore.EClass) typeObject;
    			if (type.getInstanceClass() == edu.pku.sei.AMT.Transformation.class) {
    				return parse_edu_pku_sei_AMT_Transformation();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.TypedModel.class) {
    				return parse_edu_pku_sei_AMT_TypedModel();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.Key.class) {
    				return parse_edu_pku_sei_AMT_Key();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.Rule.class) {
    				return parse_edu_pku_sei_AMT_Rule();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.ObjectVariable.class) {
    				return parse_edu_pku_sei_AMT_ObjectVariable();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.PrimitiveVariable.class) {
    				return parse_edu_pku_sei_AMT_PrimitiveVariable();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.Section.class) {
    				return parse_edu_pku_sei_AMT_Section();
    			}
    			if (type.getInstanceClass() == edu.pku.sei.AMT.LinkConstraint.class) {
    				return parse_edu_pku_sei_AMT_LinkConstraint();
    			}
    		}
    		throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptUnexpectedContentTypeException(typeObject);
    	}
    	
    	public int getMismatchedTokenRecoveryTries() {
    		return mismatchedTokenRecoveryTries;
    	}
    	
    	public Object getMissingSymbol(org.antlr.runtime3_4_0.IntStream arg0, org.antlr.runtime3_4_0.RecognitionException arg1, int arg2, org.antlr.runtime3_4_0.BitSet arg3) {
    		mismatchedTokenRecoveryTries++;
    		return super.getMissingSymbol(arg0, arg1, arg2, arg3);
    	}
    	
    	public Object getParseToIndexTypeObject() {
    		return parseToIndexTypeObject;
    	}
    	
    	protected Object getTypeObject() {
    		Object typeObject = getParseToIndexTypeObject();
    		if (typeObject != null) {
    			return typeObject;
    		}
    		java.util.Map<?,?> options = getOptions();
    		if (options != null) {
    			typeObject = options.get(edu.pku.sei.AMT.resource.amtscript.IAmtscriptOptions.RESOURCE_CONTENT_TYPE);
    		}
    		return typeObject;
    	}
    	
    	/**
    	 * Implementation that calls {@link #doParse()} and handles the thrown
    	 * RecognitionExceptions.
    	 */
    	public edu.pku.sei.AMT.resource.amtscript.IAmtscriptParseResult parse() {
    		terminateParsing = false;
    		postParseCommands = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource>>();
    		edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptParseResult parseResult = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptParseResult();
    		try {
    			org.eclipse.emf.ecore.EObject result =  doParse();
    			if (lexerExceptions.isEmpty()) {
    				parseResult.setRoot(result);
    			}
    		} catch (org.antlr.runtime3_4_0.RecognitionException re) {
    			reportError(re);
    		} catch (java.lang.IllegalArgumentException iae) {
    			if ("The 'no null' constraint is violated".equals(iae.getMessage())) {
    				// can be caused if a null is set on EMF models where not allowed. this will just
    				// happen if other errors occurred before
    			} else {
    				iae.printStackTrace();
    			}
    		}
    		for (org.antlr.runtime3_4_0.RecognitionException re : lexerExceptions) {
    			reportLexicalError(re);
    		}
    		parseResult.getPostParseCommands().addAll(postParseCommands);
    		return parseResult;
    	}
    	
    	public java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> parseToExpectedElements(org.eclipse.emf.ecore.EClass type, edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource dummyResource, int cursorOffset) {
    		this.rememberExpectedElements = true;
    		this.parseToIndexTypeObject = type;
    		this.cursorOffset = cursorOffset;
    		this.lastStartIncludingHidden = -1;
    		final org.antlr.runtime3_4_0.CommonTokenStream tokenStream = (org.antlr.runtime3_4_0.CommonTokenStream) getTokenStream();
    		edu.pku.sei.AMT.resource.amtscript.IAmtscriptParseResult result = parse();
    		for (org.eclipse.emf.ecore.EObject incompleteObject : incompleteObjects) {
    			org.antlr.runtime3_4_0.Lexer lexer = (org.antlr.runtime3_4_0.Lexer) tokenStream.getTokenSource();
    			int endChar = lexer.getCharIndex();
    			int endLine = lexer.getLine();
    			setLocalizationEnd(result.getPostParseCommands(), incompleteObject, endChar, endLine);
    		}
    		if (result != null) {
    			org.eclipse.emf.ecore.EObject root = result.getRoot();
    			if (root != null) {
    				dummyResource.getContentsInternal().add(root);
    			}
    			for (edu.pku.sei.AMT.resource.amtscript.IAmtscriptCommand<edu.pku.sei.AMT.resource.amtscript.IAmtscriptTextResource> command : result.getPostParseCommands()) {
    				command.execute(dummyResource);
    			}
    		}
    		// remove all expected elements that were added after the last complete element
    		expectedElements = expectedElements.subList(0, expectedElementsIndexOfLastCompleteElement + 1);
    		int lastFollowSetID = expectedElements.get(expectedElementsIndexOfLastCompleteElement).getFollowSetID();
    		java.util.Set<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> currentFollowSet = new java.util.LinkedHashSet<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
    		java.util.List<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal> newFollowSet = new java.util.ArrayList<edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal>();
    		for (int i = expectedElementsIndexOfLastCompleteElement; i >= 0; i--) {
    			edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElementI = expectedElements.get(i);
    			if (expectedElementI.getFollowSetID() == lastFollowSetID) {
    				currentFollowSet.add(expectedElementI);
    			} else {
    				break;
    			}
    		}
    		int followSetID = 65;
    		int i;
    		for (i = tokenIndexOfLastCompleteElement; i < tokenStream.size(); i++) {
    			org.antlr.runtime3_4_0.CommonToken nextToken = (org.antlr.runtime3_4_0.CommonToken) tokenStream.get(i);
    			if (nextToken.getType() < 0) {
    				break;
    			}
    			if (nextToken.getChannel() == 99) {
    				// hidden tokens do not reduce the follow set
    			} else {
    				// now that we have found the next visible token the position for that expected
    				// terminals can be set
    				for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : newFollowSet) {
    					lastTokenIndex = 0;
    					setPosition(nextFollow, i);
    				}
    				newFollowSet.clear();
    				// normal tokens do reduce the follow set - only elements that match the token are
    				// kept
    				for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : currentFollowSet) {
    					if (nextFollow.getTerminal().getTokenNames().contains(getTokenNames()[nextToken.getType()])) {
    						// keep this one - it matches
    						java.util.Collection<edu.pku.sei.AMT.resource.amtscript.util.AmtscriptPair<edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[]>> newFollowers = nextFollow.getTerminal().getFollowers();
    						for (edu.pku.sei.AMT.resource.amtscript.util.AmtscriptPair<edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContainedFeature[]> newFollowerPair : newFollowers) {
    							edu.pku.sei.AMT.resource.amtscript.IAmtscriptExpectedElement newFollower = newFollowerPair.getLeft();
    							org.eclipse.emf.ecore.EObject container = getLastIncompleteElement();
    							edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace containmentTrace = new edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptContainmentTrace(null, newFollowerPair.getRight());
    							edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal newFollowTerminal = new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal(container, newFollower, followSetID, containmentTrace);
    							newFollowSet.add(newFollowTerminal);
    							expectedElements.add(newFollowTerminal);
    						}
    					}
    				}
    				currentFollowSet.clear();
    				currentFollowSet.addAll(newFollowSet);
    			}
    			followSetID++;
    		}
    		// after the last token in the stream we must set the position for the elements
    		// that were added during the last iteration of the loop
    		for (edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal nextFollow : newFollowSet) {
    			lastTokenIndex = 0;
    			setPosition(nextFollow, i);
    		}
    		return this.expectedElements;
    	}
    	
    	public void setPosition(edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectedTerminal expectedElement, int tokenIndex) {
    		int currentIndex = Math.max(0, tokenIndex);
    		for (int index = lastTokenIndex; index < currentIndex; index++) {
    			if (index >= input.size()) {
    				break;
    			}
    			org.antlr.runtime3_4_0.CommonToken tokenAtIndex = (org.antlr.runtime3_4_0.CommonToken) input.get(index);
    			stopIncludingHiddenTokens = tokenAtIndex.getStopIndex() + 1;
    			if (tokenAtIndex.getChannel() != 99 && !anonymousTokens.contains(tokenAtIndex)) {
    				stopExcludingHiddenTokens = tokenAtIndex.getStopIndex() + 1;
    			}
    		}
    		lastTokenIndex = Math.max(0, currentIndex);
    		expectedElement.setPosition(stopExcludingHiddenTokens, stopIncludingHiddenTokens);
    	}
    	
    	public Object recoverFromMismatchedToken(org.antlr.runtime3_4_0.IntStream input, int ttype, org.antlr.runtime3_4_0.BitSet follow) throws org.antlr.runtime3_4_0.RecognitionException {
    		if (!rememberExpectedElements) {
    			return super.recoverFromMismatchedToken(input, ttype, follow);
    		} else {
    			return null;
    		}
    	}
    	
    	/**
    	 * Translates errors thrown by the parser into human readable messages.
    	 */
    	public void reportError(final org.antlr.runtime3_4_0.RecognitionException e)  {
    		String message = e.getMessage();
    		if (e instanceof org.antlr.runtime3_4_0.MismatchedTokenException) {
    			org.antlr.runtime3_4_0.MismatchedTokenException mte = (org.antlr.runtime3_4_0.MismatchedTokenException) e;
    			String expectedTokenName = formatTokenName(mte.expecting);
    			String actualTokenName = formatTokenName(e.token.getType());
    			message = "Syntax error on token \"" + e.token.getText() + " (" + actualTokenName + ")\", \"" + expectedTokenName + "\" expected";
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedTreeNodeException) {
    			org.antlr.runtime3_4_0.MismatchedTreeNodeException mtne = (org.antlr.runtime3_4_0.MismatchedTreeNodeException) e;
    			String expectedTokenName = formatTokenName(mtne.expecting);
    			message = "mismatched tree node: " + "xxx" + "; tokenName " + expectedTokenName;
    		} else if (e instanceof org.antlr.runtime3_4_0.NoViableAltException) {
    			message = "Syntax error on token \"" + e.token.getText() + "\", check following tokens";
    		} else if (e instanceof org.antlr.runtime3_4_0.EarlyExitException) {
    			message = "Syntax error on token \"" + e.token.getText() + "\", delete this token";
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedSetException) {
    			org.antlr.runtime3_4_0.MismatchedSetException mse = (org.antlr.runtime3_4_0.MismatchedSetException) e;
    			message = "mismatched token: " + e.token + "; expecting set " + mse.expecting;
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedNotSetException) {
    			org.antlr.runtime3_4_0.MismatchedNotSetException mse = (org.antlr.runtime3_4_0.MismatchedNotSetException) e;
    			message = "mismatched token: " +  e.token + "; expecting set " + mse.expecting;
    		} else if (e instanceof org.antlr.runtime3_4_0.FailedPredicateException) {
    			org.antlr.runtime3_4_0.FailedPredicateException fpe = (org.antlr.runtime3_4_0.FailedPredicateException) e;
    			message = "rule " + fpe.ruleName + " failed predicate: {" +  fpe.predicateText + "}?";
    		}
    		// the resource may be null if the parser is used for code completion
    		final String finalMessage = message;
    		if (e.token instanceof org.antlr.runtime3_4_0.CommonToken) {
    			final org.antlr.runtime3_4_0.CommonToken ct = (org.antlr.runtime3_4_0.CommonToken) e.token;
    			addErrorToResource(finalMessage, ct.getCharPositionInLine(), ct.getLine(), ct.getStartIndex(), ct.getStopIndex());
    		} else {
    			addErrorToResource(finalMessage, e.token.getCharPositionInLine(), e.token.getLine(), 1, 5);
    		}
    	}
    	
    	/**
    	 * Translates errors thrown by the lexer into human readable messages.
    	 */
    	public void reportLexicalError(final org.antlr.runtime3_4_0.RecognitionException e)  {
    		String message = "";
    		if (e instanceof org.antlr.runtime3_4_0.MismatchedTokenException) {
    			org.antlr.runtime3_4_0.MismatchedTokenException mte = (org.antlr.runtime3_4_0.MismatchedTokenException) e;
    			message = "Syntax error on token \"" + ((char) e.c) + "\", \"" + (char) mte.expecting + "\" expected";
    		} else if (e instanceof org.antlr.runtime3_4_0.NoViableAltException) {
    			message = "Syntax error on token \"" + ((char) e.c) + "\", delete this token";
    		} else if (e instanceof org.antlr.runtime3_4_0.EarlyExitException) {
    			org.antlr.runtime3_4_0.EarlyExitException eee = (org.antlr.runtime3_4_0.EarlyExitException) e;
    			message = "required (...)+ loop (decision=" + eee.decisionNumber + ") did not match anything; on line " + e.line + ":" + e.charPositionInLine + " char=" + ((char) e.c) + "'";
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedSetException) {
    			org.antlr.runtime3_4_0.MismatchedSetException mse = (org.antlr.runtime3_4_0.MismatchedSetException) e;
    			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set " + mse.expecting;
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedNotSetException) {
    			org.antlr.runtime3_4_0.MismatchedNotSetException mse = (org.antlr.runtime3_4_0.MismatchedNotSetException) e;
    			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set " + mse.expecting;
    		} else if (e instanceof org.antlr.runtime3_4_0.MismatchedRangeException) {
    			org.antlr.runtime3_4_0.MismatchedRangeException mre = (org.antlr.runtime3_4_0.MismatchedRangeException) e;
    			message = "mismatched char: '" + ((char) e.c) + "' on line " + e.line + ":" + e.charPositionInLine + "; expecting set '" + (char) mre.a + "'..'" + (char) mre.b + "'";
    		} else if (e instanceof org.antlr.runtime3_4_0.FailedPredicateException) {
    			org.antlr.runtime3_4_0.FailedPredicateException fpe = (org.antlr.runtime3_4_0.FailedPredicateException) e;
    			message = "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
    		}
    		addErrorToResource(message, e.charPositionInLine, e.line, lexerExceptionsPosition.get(lexerExceptions.indexOf(e)), lexerExceptionsPosition.get(lexerExceptions.indexOf(e)));
    	}
    	
    	private void startIncompleteElement(Object object) {
    		if (object instanceof org.eclipse.emf.ecore.EObject) {
    			this.incompleteObjects.add((org.eclipse.emf.ecore.EObject) object);
    		}
    	}
    	
    	private void completedElement(Object object, boolean isContainment) {
    		if (isContainment && !this.incompleteObjects.isEmpty()) {
    			boolean exists = this.incompleteObjects.remove(object);
    			if (!exists) {
    			}
    		}
    		if (object instanceof org.eclipse.emf.ecore.EObject) {
    			this.tokenIndexOfLastCompleteElement = getTokenStream().index();
    			this.expectedElementsIndexOfLastCompleteElement = expectedElements.size() - 1;
    		}
    	}
    	
    	private org.eclipse.emf.ecore.EObject getLastIncompleteElement() {
    		if (incompleteObjects.isEmpty()) {
    			return null;
    		}
    		return incompleteObjects.get(incompleteObjects.size() - 1);
    	}
    	



    // $ANTLR start "start"
    // Amtscript.g:520:1: start returns [ org.eclipse.emf.ecore.EObject element = null] : (c0= parse_edu_pku_sei_AMT_Transformation ) EOF ;
    public final org.eclipse.emf.ecore.EObject start() throws RecognitionException {
        org.eclipse.emf.ecore.EObject element =  null;

        int start_StartIndex = input.index();

        edu.pku.sei.AMT.Transformation c0 =null;


        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 1) ) { return element; }

            // Amtscript.g:521:2: ( (c0= parse_edu_pku_sei_AMT_Transformation ) EOF )
            // Amtscript.g:522:2: (c0= parse_edu_pku_sei_AMT_Transformation ) EOF
            {
            if ( state.backtracking==0 ) {
            		// follow set for start rule(s)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[0]);
            		expectedElementsIndexOfLastCompleteElement = 0;
            	}

            // Amtscript.g:527:2: (c0= parse_edu_pku_sei_AMT_Transformation )
            // Amtscript.g:528:3: c0= parse_edu_pku_sei_AMT_Transformation
            {
            pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Transformation_in_start82);
            c0=parse_edu_pku_sei_AMT_Transformation();

            state._fsp--;
            if (state.failed) return element;

            if ( state.backtracking==0 ) { element = c0; }

            }


            match(input,EOF,FOLLOW_EOF_in_start89); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		retrieveLayoutInformation(element, null, null, false);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 1, start_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "start"



    // $ANTLR start "parse_edu_pku_sei_AMT_Transformation"
    // Amtscript.g:536:1: parse_edu_pku_sei_AMT_Transformation returns [edu.pku.sei.AMT.Transformation element = null] : a0= 'transformation' (a1= IDENTIFIER ) ( ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* ) )? ( (a5_0= parse_edu_pku_sei_AMT_Key ) )* ( (a6_0= parse_edu_pku_sei_AMT_Rule ) )* ;
    public final edu.pku.sei.AMT.Transformation parse_edu_pku_sei_AMT_Transformation() throws RecognitionException {
        edu.pku.sei.AMT.Transformation element =  null;

        int parse_edu_pku_sei_AMT_Transformation_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a3=null;
        edu.pku.sei.AMT.TypedModel a2_0 =null;

        edu.pku.sei.AMT.TypedModel a4_0 =null;

        edu.pku.sei.AMT.Key a5_0 =null;

        edu.pku.sei.AMT.Rule a6_0 =null;




        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 2) ) { return element; }

            // Amtscript.g:539:2: (a0= 'transformation' (a1= IDENTIFIER ) ( ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* ) )? ( (a5_0= parse_edu_pku_sei_AMT_Key ) )* ( (a6_0= parse_edu_pku_sei_AMT_Rule ) )* )
            // Amtscript.g:540:2: a0= 'transformation' (a1= IDENTIFIER ) ( ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* ) )? ( (a5_0= parse_edu_pku_sei_AMT_Key ) )* ( (a6_0= parse_edu_pku_sei_AMT_Rule ) )*
            {
            a0=(Token)match(input,19,FOLLOW_19_in_parse_edu_pku_sei_AMT_Transformation115); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_0, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[1]);
            	}

            // Amtscript.g:554:2: (a1= IDENTIFIER )
            // Amtscript.g:555:3: a1= IDENTIFIER
            {
            a1=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Transformation133); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
            				startIncompleteElement(element);
            			}
            			if (a1 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_1, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[2]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[3]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[4]);
            	}

            // Amtscript.g:592:2: ( ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* ) )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==IDENTIFIER) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // Amtscript.g:593:3: ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* )
                    {
                    // Amtscript.g:593:3: ( (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )* )
                    // Amtscript.g:594:4: (a2_0= parse_edu_pku_sei_AMT_TypedModel ) ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )*
                    {
                    // Amtscript.g:594:4: (a2_0= parse_edu_pku_sei_AMT_TypedModel )
                    // Amtscript.g:595:5: a2_0= parse_edu_pku_sei_AMT_TypedModel
                    {
                    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_TypedModel_in_parse_edu_pku_sei_AMT_Transformation169);
                    a2_0=parse_edu_pku_sei_AMT_TypedModel();

                    state._fsp--;
                    if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    					if (terminateParsing) {
                    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    					}
                    					if (element == null) {
                    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
                    						startIncompleteElement(element);
                    					}
                    					if (a2_0 != null) {
                    						if (a2_0 != null) {
                    							Object value = a2_0;
                    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__PARAMETERS, value);
                    							completedElement(value, true);
                    						}
                    						collectHiddenTokens(element);
                    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_0, a2_0, true);
                    						copyLocalizationInfos(a2_0, element);
                    					}
                    				}

                    }


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[5]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[6]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[7]);
                    			}

                    // Amtscript.g:622:4: ( (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) ) )*
                    loop1:
                    do {
                        int alt1=2;
                        int LA1_0 = input.LA(1);

                        if ( (LA1_0==10) ) {
                            alt1=1;
                        }


                        switch (alt1) {
                    	case 1 :
                    	    // Amtscript.g:623:5: (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) )
                    	    {
                    	    // Amtscript.g:623:5: (a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel ) )
                    	    // Amtscript.g:624:6: a3= ',' (a4_0= parse_edu_pku_sei_AMT_TypedModel )
                    	    {
                    	    a3=(Token)match(input,10,FOLLOW_10_in_parse_edu_pku_sei_AMT_Transformation210); if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    						if (element == null) {
                    	    							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
                    	    							startIncompleteElement(element);
                    	    						}
                    	    						collectHiddenTokens(element);
                    	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_1_0_0_0, null, true);
                    	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
                    	    					}

                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[8]);
                    	    					}

                    	    // Amtscript.g:638:6: (a4_0= parse_edu_pku_sei_AMT_TypedModel )
                    	    // Amtscript.g:639:7: a4_0= parse_edu_pku_sei_AMT_TypedModel
                    	    {
                    	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_TypedModel_in_parse_edu_pku_sei_AMT_Transformation244);
                    	    a4_0=parse_edu_pku_sei_AMT_TypedModel();

                    	    state._fsp--;
                    	    if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    							if (terminateParsing) {
                    	    								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    	    							}
                    	    							if (element == null) {
                    	    								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
                    	    								startIncompleteElement(element);
                    	    							}
                    	    							if (a4_0 != null) {
                    	    								if (a4_0 != null) {
                    	    									Object value = a4_0;
                    	    									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__PARAMETERS, value);
                    	    									completedElement(value, true);
                    	    								}
                    	    								collectHiddenTokens(element);
                    	    								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_2_0_0_1_0_0_1, a4_0, true);
                    	    								copyLocalizationInfos(a4_0, element);
                    	    							}
                    	    						}

                    	    }


                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[9]);
                    	    						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[10]);
                    	    						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[11]);
                    	    					}

                    	    }


                    	    }
                    	    break;

                    	default :
                    	    break loop1;
                        }
                    } while (true);


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[12]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[13]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[14]);
                    			}

                    }


                    }
                    break;

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[15]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[16]);
            	}

            // Amtscript.g:683:2: ( (a5_0= parse_edu_pku_sei_AMT_Key ) )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==17) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // Amtscript.g:684:3: (a5_0= parse_edu_pku_sei_AMT_Key )
            	    {
            	    // Amtscript.g:684:3: (a5_0= parse_edu_pku_sei_AMT_Key )
            	    // Amtscript.g:685:4: a5_0= parse_edu_pku_sei_AMT_Key
            	    {
            	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Key_in_parse_edu_pku_sei_AMT_Transformation327);
            	    a5_0=parse_edu_pku_sei_AMT_Key();

            	    state._fsp--;
            	    if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (terminateParsing) {
            	    					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    				}
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
            	    					startIncompleteElement(element);
            	    				}
            	    				if (a5_0 != null) {
            	    					if (a5_0 != null) {
            	    						Object value = a5_0;
            	    						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__KEYS, value);
            	    						completedElement(value, true);
            	    					}
            	    					collectHiddenTokens(element);
            	    					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_3, a5_0, true);
            	    					copyLocalizationInfos(a5_0, element);
            	    				}
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[17]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[18]);
            	}

            // Amtscript.g:712:2: ( (a6_0= parse_edu_pku_sei_AMT_Rule ) )*
            loop4:
            do {
                int alt4=2;
                int LA4_0 = input.LA(1);

                if ( (LA4_0==18) ) {
                    alt4=1;
                }


                switch (alt4) {
            	case 1 :
            	    // Amtscript.g:713:3: (a6_0= parse_edu_pku_sei_AMT_Rule )
            	    {
            	    // Amtscript.g:713:3: (a6_0= parse_edu_pku_sei_AMT_Rule )
            	    // Amtscript.g:714:4: a6_0= parse_edu_pku_sei_AMT_Rule
            	    {
            	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Rule_in_parse_edu_pku_sei_AMT_Transformation362);
            	    a6_0=parse_edu_pku_sei_AMT_Rule();

            	    state._fsp--;
            	    if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (terminateParsing) {
            	    					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    				}
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTransformation();
            	    					startIncompleteElement(element);
            	    				}
            	    				if (a6_0 != null) {
            	    					if (a6_0 != null) {
            	    						Object value = a6_0;
            	    						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.TRANSFORMATION__RULES, value);
            	    						completedElement(value, true);
            	    					}
            	    					collectHiddenTokens(element);
            	    					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_0_0_0_4, a6_0, true);
            	    					copyLocalizationInfos(a6_0, element);
            	    				}
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[19]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 2, parse_edu_pku_sei_AMT_Transformation_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_Transformation"



    // $ANTLR start "parse_edu_pku_sei_AMT_TypedModel"
    // Amtscript.g:742:1: parse_edu_pku_sei_AMT_TypedModel returns [edu.pku.sei.AMT.TypedModel element = null] : (a0= IDENTIFIER ) a1= ':' (a2= URI ) ;
    public final edu.pku.sei.AMT.TypedModel parse_edu_pku_sei_AMT_TypedModel() throws RecognitionException {
        edu.pku.sei.AMT.TypedModel element =  null;

        int parse_edu_pku_sei_AMT_TypedModel_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;



        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 3) ) { return element; }

            // Amtscript.g:745:2: ( (a0= IDENTIFIER ) a1= ':' (a2= URI ) )
            // Amtscript.g:746:2: (a0= IDENTIFIER ) a1= ':' (a2= URI )
            {
            // Amtscript.g:746:2: (a0= IDENTIFIER )
            // Amtscript.g:747:3: a0= IDENTIFIER
            {
            a0=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_TypedModel407); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
            				startIncompleteElement(element);
            			}
            			if (a0 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_0, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[20]);
            	}

            a1=(Token)match(input,12,FOLLOW_12_in_parse_edu_pku_sei_AMT_TypedModel428); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_1, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[21]);
            	}

            // Amtscript.g:796:2: (a2= URI )
            // Amtscript.g:797:3: a2= URI
            {
            a2=(Token)match(input,URI,FOLLOW_URI_in_parse_edu_pku_sei_AMT_TypedModel446); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createTypedModel();
            				startIncompleteElement(element);
            			}
            			if (a2 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("URI");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__URI), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.TYPED_MODEL__URI), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_1_0_0_2, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[22]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[23]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[24]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 3, parse_edu_pku_sei_AMT_TypedModel_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_TypedModel"



    // $ANTLR start "parse_edu_pku_sei_AMT_Key"
    // Amtscript.g:836:1: parse_edu_pku_sei_AMT_Key returns [edu.pku.sei.AMT.Key element = null] : a0= 'key' (a1= IDENTIFIER ) a2= ':' ( ( (a3= KEYFEATURENAME ) ) )+ a4= ';' ;
    public final edu.pku.sei.AMT.Key parse_edu_pku_sei_AMT_Key() throws RecognitionException {
        edu.pku.sei.AMT.Key element =  null;

        int parse_edu_pku_sei_AMT_Key_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;
        Token a3=null;
        Token a4=null;



        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 4) ) { return element; }

            // Amtscript.g:839:2: (a0= 'key' (a1= IDENTIFIER ) a2= ':' ( ( (a3= KEYFEATURENAME ) ) )+ a4= ';' )
            // Amtscript.g:840:2: a0= 'key' (a1= IDENTIFIER ) a2= ':' ( ( (a3= KEYFEATURENAME ) ) )+ a4= ';'
            {
            a0=(Token)match(input,17,FOLLOW_17_in_parse_edu_pku_sei_AMT_Key482); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_0, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[25]);
            	}

            // Amtscript.g:854:2: (a1= IDENTIFIER )
            // Amtscript.g:855:3: a1= IDENTIFIER
            {
            a1=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Key500); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
            				startIncompleteElement(element);
            			}
            			if (a1 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__CLASS_NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__CLASS_NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_1, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[26]);
            	}

            a2=(Token)match(input,12,FOLLOW_12_in_parse_edu_pku_sei_AMT_Key521); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_2, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a2, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[27]);
            	}

            // Amtscript.g:904:2: ( ( (a3= KEYFEATURENAME ) ) )+
            int cnt5=0;
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( (LA5_0==KEYFEATURENAME) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // Amtscript.g:905:3: ( (a3= KEYFEATURENAME ) )
            	    {
            	    // Amtscript.g:905:3: ( (a3= KEYFEATURENAME ) )
            	    // Amtscript.g:906:4: (a3= KEYFEATURENAME )
            	    {
            	    // Amtscript.g:906:4: (a3= KEYFEATURENAME )
            	    // Amtscript.g:907:5: a3= KEYFEATURENAME
            	    {
            	    a3=(Token)match(input,KEYFEATURENAME,FOLLOW_KEYFEATURENAME_in_parse_edu_pku_sei_AMT_Key550); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    					if (terminateParsing) {
            	    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    					}
            	    					if (element == null) {
            	    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
            	    						startIncompleteElement(element);
            	    					}
            	    					if (a3 != null) {
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("KEYFEATURENAME");
            	    						tokenResolver.setOptions(getOptions());
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            	    						tokenResolver.resolve(a3.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.KEY__FEATURE_NAMES), result);
            	    						Object resolvedObject = result.getResolvedToken();
            	    						if (resolvedObject == null) {
            	    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a3).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a3).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a3).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a3).getStopIndex());
            	    						}
            	    						java.lang.String resolved = (java.lang.String) resolvedObject;
            	    						if (resolved != null) {
            	    							Object value = resolved;
            	    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.KEY__FEATURE_NAMES, value);
            	    							completedElement(value, false);
            	    						}
            	    						collectHiddenTokens(element);
            	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_3_0_0_0, resolved, true);
            	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a3, element);
            	    					}
            	    				}

            	    }


            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[28]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[29]);
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    if ( cnt5 >= 1 ) break loop5;
            	    if (state.backtracking>0) {state.failed=true; return element;}
                        EarlyExitException eee =
                            new EarlyExitException(5, input);
                        throw eee;
                }
                cnt5++;
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[30]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[31]);
            	}

            a4=(Token)match(input,14,FOLLOW_14_in_parse_edu_pku_sei_AMT_Key596); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createKey();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_2_0_0_4, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a4, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[32]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[33]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 4, parse_edu_pku_sei_AMT_Key_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_Key"



    // $ANTLR start "parse_edu_pku_sei_AMT_Rule"
    // Amtscript.g:968:1: parse_edu_pku_sei_AMT_Rule returns [edu.pku.sei.AMT.Rule element = null] : a0= 'rule' ( ( (a1= IDENTIFIER ) ) )* (a2= IDENTIFIER ) a3= '{' ( ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' ) )* ( (a6_0= parse_edu_pku_sei_AMT_Section ) )* a7= '}' ;
    public final edu.pku.sei.AMT.Rule parse_edu_pku_sei_AMT_Rule() throws RecognitionException {
        edu.pku.sei.AMT.Rule element =  null;

        int parse_edu_pku_sei_AMT_Rule_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;
        Token a3=null;
        Token a5=null;
        Token a7=null;
        edu.pku.sei.AMT.Variable a4_0 =null;

        edu.pku.sei.AMT.Section a6_0 =null;




        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 5) ) { return element; }

            // Amtscript.g:971:2: (a0= 'rule' ( ( (a1= IDENTIFIER ) ) )* (a2= IDENTIFIER ) a3= '{' ( ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' ) )* ( (a6_0= parse_edu_pku_sei_AMT_Section ) )* a7= '}' )
            // Amtscript.g:972:2: a0= 'rule' ( ( (a1= IDENTIFIER ) ) )* (a2= IDENTIFIER ) a3= '{' ( ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' ) )* ( (a6_0= parse_edu_pku_sei_AMT_Section ) )* a7= '}'
            {
            a0=(Token)match(input,18,FOLLOW_18_in_parse_edu_pku_sei_AMT_Rule625); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_0, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a0, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[34]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[35]);
            	}

            // Amtscript.g:987:2: ( ( (a1= IDENTIFIER ) ) )*
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==IDENTIFIER) ) {
                    int LA6_1 = input.LA(2);

                    if ( (LA6_1==IDENTIFIER) ) {
                        alt6=1;
                    }


                }


                switch (alt6) {
            	case 1 :
            	    // Amtscript.g:988:3: ( (a1= IDENTIFIER ) )
            	    {
            	    // Amtscript.g:988:3: ( (a1= IDENTIFIER ) )
            	    // Amtscript.g:989:4: (a1= IDENTIFIER )
            	    {
            	    // Amtscript.g:989:4: (a1= IDENTIFIER )
            	    // Amtscript.g:990:5: a1= IDENTIFIER
            	    {
            	    a1=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Rule654); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    					if (terminateParsing) {
            	    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    					}
            	    					if (element == null) {
            	    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            	    						startIncompleteElement(element);
            	    					}
            	    					if (a1 != null) {
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            	    						tokenResolver.setOptions(getOptions());
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            	    						tokenResolver.resolve(a1.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__MODIFIERS), result);
            	    						Object resolvedObject = result.getResolvedToken();
            	    						if (resolvedObject == null) {
            	    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a1).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a1).getStopIndex());
            	    						}
            	    						java.lang.String resolved = (java.lang.String) resolvedObject;
            	    						if (resolved != null) {
            	    							Object value = resolved;
            	    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__MODIFIERS, value);
            	    							completedElement(value, false);
            	    						}
            	    						collectHiddenTokens(element);
            	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_1_0_0_0, resolved, true);
            	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a1, element);
            	    					}
            	    				}

            	    }


            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[36]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[37]);
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop6;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[38]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[39]);
            	}

            // Amtscript.g:1034:2: (a2= IDENTIFIER )
            // Amtscript.g:1035:3: a2= IDENTIFIER
            {
            a2=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Rule704); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            				startIncompleteElement(element);
            			}
            			if (a2 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.RULE__NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_2, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[40]);
            	}

            a3=(Token)match(input,20,FOLLOW_20_in_parse_edu_pku_sei_AMT_Rule725); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_3, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[41]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[42]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[43]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[44]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[45]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[46]);
            	}

            // Amtscript.g:1089:2: ( ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' ) )*
            loop7:
            do {
                int alt7=2;
                int LA7_0 = input.LA(1);

                if ( (LA7_0==IDENTIFIER) ) {
                    int LA7_1 = input.LA(2);

                    if ( (LA7_1==12) ) {
                        alt7=1;
                    }


                }


                switch (alt7) {
            	case 1 :
            	    // Amtscript.g:1090:3: ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' )
            	    {
            	    // Amtscript.g:1090:3: ( (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';' )
            	    // Amtscript.g:1091:4: (a4_0= parse_edu_pku_sei_AMT_Variable ) a5= ';'
            	    {
            	    // Amtscript.g:1091:4: (a4_0= parse_edu_pku_sei_AMT_Variable )
            	    // Amtscript.g:1092:5: a4_0= parse_edu_pku_sei_AMT_Variable
            	    {
            	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Variable_in_parse_edu_pku_sei_AMT_Rule754);
            	    a4_0=parse_edu_pku_sei_AMT_Variable();

            	    state._fsp--;
            	    if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    					if (terminateParsing) {
            	    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    					}
            	    					if (element == null) {
            	    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            	    						startIncompleteElement(element);
            	    					}
            	    					if (a4_0 != null) {
            	    						if (a4_0 != null) {
            	    							Object value = a4_0;
            	    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__VARIABLES, value);
            	    							completedElement(value, true);
            	    						}
            	    						collectHiddenTokens(element);
            	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_4_0_0_0, a4_0, true);
            	    						copyLocalizationInfos(a4_0, element);
            	    					}
            	    				}

            	    }


            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[47]);
            	    			}

            	    a5=(Token)match(input,14,FOLLOW_14_in_parse_edu_pku_sei_AMT_Rule782); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            	    					startIncompleteElement(element);
            	    				}
            	    				collectHiddenTokens(element);
            	    				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_4_0_0_1, null, true);
            	    				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a5, element);
            	    			}

            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[48]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[49]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[50]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[51]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[52]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[53]);
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop7;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[54]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[55]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[56]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[57]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[58]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[59]);
            	}

            // Amtscript.g:1148:2: ( (a6_0= parse_edu_pku_sei_AMT_Section ) )*
            loop8:
            do {
                int alt8=2;
                int LA8_0 = input.LA(1);

                if ( (LA8_0==IDENTIFIER||LA8_0==16||LA8_0==20) ) {
                    alt8=1;
                }


                switch (alt8) {
            	case 1 :
            	    // Amtscript.g:1149:3: (a6_0= parse_edu_pku_sei_AMT_Section )
            	    {
            	    // Amtscript.g:1149:3: (a6_0= parse_edu_pku_sei_AMT_Section )
            	    // Amtscript.g:1150:4: a6_0= parse_edu_pku_sei_AMT_Section
            	    {
            	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Section_in_parse_edu_pku_sei_AMT_Rule824);
            	    a6_0=parse_edu_pku_sei_AMT_Section();

            	    state._fsp--;
            	    if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (terminateParsing) {
            	    					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    				}
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            	    					startIncompleteElement(element);
            	    				}
            	    				if (a6_0 != null) {
            	    					if (a6_0 != null) {
            	    						Object value = a6_0;
            	    						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.RULE__SECTIONS, value);
            	    						completedElement(value, true);
            	    					}
            	    					collectHiddenTokens(element);
            	    					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_5, a6_0, true);
            	    					copyLocalizationInfos(a6_0, element);
            	    				}
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop8;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[60]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[61]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[62]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[63]);
            	}

            a7=(Token)match(input,21,FOLLOW_21_in_parse_edu_pku_sei_AMT_Rule850); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createRule();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_3_0_0_6, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a7, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getTransformation(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[64]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 5, parse_edu_pku_sei_AMT_Rule_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_Rule"



    // $ANTLR start "parse_edu_pku_sei_AMT_ObjectVariable"
    // Amtscript.g:1195:1: parse_edu_pku_sei_AMT_ObjectVariable returns [edu.pku.sei.AMT.ObjectVariable element = null] : (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER ) a3= '::' (a4= IDENTIFIER ) ;
    public final edu.pku.sei.AMT.ObjectVariable parse_edu_pku_sei_AMT_ObjectVariable() throws RecognitionException {
        edu.pku.sei.AMT.ObjectVariable element =  null;

        int parse_edu_pku_sei_AMT_ObjectVariable_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;
        Token a3=null;
        Token a4=null;



        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 6) ) { return element; }

            // Amtscript.g:1198:2: ( (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER ) a3= '::' (a4= IDENTIFIER ) )
            // Amtscript.g:1199:2: (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER ) a3= '::' (a4= IDENTIFIER )
            {
            // Amtscript.g:1199:2: (a0= IDENTIFIER )
            // Amtscript.g:1200:3: a0= IDENTIFIER
            {
            a0=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable883); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            				startIncompleteElement(element);
            			}
            			if (a0 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_0, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[65]);
            	}

            a1=(Token)match(input,12,FOLLOW_12_in_parse_edu_pku_sei_AMT_ObjectVariable904); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_1, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[66]);
            	}

            // Amtscript.g:1249:2: (a2= IDENTIFIER )
            // Amtscript.g:1250:3: a2= IDENTIFIER
            {
            a2=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable922); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            				startIncompleteElement(element);
            			}
            			if (a2 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__SCOPE), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__SCOPE), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_2, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[67]);
            	}

            a3=(Token)match(input,13,FOLLOW_13_in_parse_edu_pku_sei_AMT_ObjectVariable943); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_3, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[68]);
            	}

            // Amtscript.g:1299:2: (a4= IDENTIFIER )
            // Amtscript.g:1300:3: a4= IDENTIFIER
            {
            a4=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable961); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            				startIncompleteElement(element);
            			}
            			if (a4 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__TYPE), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.OBJECT_VARIABLE__TYPE), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_4_0_0_4, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[69]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 6, parse_edu_pku_sei_AMT_ObjectVariable_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_ObjectVariable"



    // $ANTLR start "parse_edu_pku_sei_AMT_PrimitiveVariable"
    // Amtscript.g:1337:1: parse_edu_pku_sei_AMT_PrimitiveVariable returns [edu.pku.sei.AMT.PrimitiveVariable element = null] : (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER ) ;
    public final edu.pku.sei.AMT.PrimitiveVariable parse_edu_pku_sei_AMT_PrimitiveVariable() throws RecognitionException {
        edu.pku.sei.AMT.PrimitiveVariable element =  null;

        int parse_edu_pku_sei_AMT_PrimitiveVariable_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;



        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 7) ) { return element; }

            // Amtscript.g:1340:2: ( (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER ) )
            // Amtscript.g:1341:2: (a0= IDENTIFIER ) a1= ':' (a2= IDENTIFIER )
            {
            // Amtscript.g:1341:2: (a0= IDENTIFIER )
            // Amtscript.g:1342:3: a0= IDENTIFIER
            {
            a0=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_PrimitiveVariable1001); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
            				startIncompleteElement(element);
            			}
            			if (a0 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_0, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[70]);
            	}

            a1=(Token)match(input,12,FOLLOW_12_in_parse_edu_pku_sei_AMT_PrimitiveVariable1022); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_1, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[71]);
            	}

            // Amtscript.g:1391:2: (a2= IDENTIFIER )
            // Amtscript.g:1392:3: a2= IDENTIFIER
            {
            a2=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_PrimitiveVariable1040); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
            				startIncompleteElement(element);
            			}
            			if (a2 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__TYPE), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.PRIMITIVE_VARIABLE__TYPE), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_5_0_0_2, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[72]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 7, parse_edu_pku_sei_AMT_PrimitiveVariable_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_PrimitiveVariable"



    // $ANTLR start "parse_edu_pku_sei_AMT_Section"
    // Amtscript.g:1429:1: parse_edu_pku_sei_AMT_Section returns [edu.pku.sei.AMT.Section element = null] : ( ( (a0= IDENTIFIER ) ) )* ( (a1= 'for' (a2= IDENTIFIER ) ) )? a3= '{' ( ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' ) )? ( ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' ) )? ( ( (a12= EXPR ) a13= ';' ) )* ( (a14_0= parse_edu_pku_sei_AMT_Section ) )* a15= '}' ;
    public final edu.pku.sei.AMT.Section parse_edu_pku_sei_AMT_Section() throws RecognitionException {
        edu.pku.sei.AMT.Section element =  null;

        int parse_edu_pku_sei_AMT_Section_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;
        Token a3=null;
        Token a4=null;
        Token a5=null;
        Token a6=null;
        Token a7=null;
        Token a9=null;
        Token a11=null;
        Token a12=null;
        Token a13=null;
        Token a15=null;
        edu.pku.sei.AMT.LinkConstraint a8_0 =null;

        edu.pku.sei.AMT.LinkConstraint a10_0 =null;

        edu.pku.sei.AMT.Section a14_0 =null;




        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 8) ) { return element; }

            // Amtscript.g:1432:2: ( ( ( (a0= IDENTIFIER ) ) )* ( (a1= 'for' (a2= IDENTIFIER ) ) )? a3= '{' ( ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' ) )? ( ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' ) )? ( ( (a12= EXPR ) a13= ';' ) )* ( (a14_0= parse_edu_pku_sei_AMT_Section ) )* a15= '}' )
            // Amtscript.g:1433:2: ( ( (a0= IDENTIFIER ) ) )* ( (a1= 'for' (a2= IDENTIFIER ) ) )? a3= '{' ( ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' ) )? ( ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' ) )? ( ( (a12= EXPR ) a13= ';' ) )* ( (a14_0= parse_edu_pku_sei_AMT_Section ) )* a15= '}'
            {
            // Amtscript.g:1433:2: ( ( (a0= IDENTIFIER ) ) )*
            loop9:
            do {
                int alt9=2;
                int LA9_0 = input.LA(1);

                if ( (LA9_0==IDENTIFIER) ) {
                    alt9=1;
                }


                switch (alt9) {
            	case 1 :
            	    // Amtscript.g:1434:3: ( (a0= IDENTIFIER ) )
            	    {
            	    // Amtscript.g:1434:3: ( (a0= IDENTIFIER ) )
            	    // Amtscript.g:1435:4: (a0= IDENTIFIER )
            	    {
            	    // Amtscript.g:1435:4: (a0= IDENTIFIER )
            	    // Amtscript.g:1436:5: a0= IDENTIFIER
            	    {
            	    a0=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1091); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    					if (terminateParsing) {
            	    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    					}
            	    					if (element == null) {
            	    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            	    						startIncompleteElement(element);
            	    					}
            	    					if (a0 != null) {
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            	    						tokenResolver.setOptions(getOptions());
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            	    						tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODIFIERS), result);
            	    						Object resolvedObject = result.getResolvedToken();
            	    						if (resolvedObject == null) {
            	    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
            	    						}
            	    						java.lang.String resolved = (java.lang.String) resolvedObject;
            	    						if (resolved != null) {
            	    							Object value = resolved;
            	    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__MODIFIERS, value);
            	    							completedElement(value, false);
            	    						}
            	    						collectHiddenTokens(element);
            	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_0_0_0_0, resolved, true);
            	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
            	    					}
            	    				}

            	    }


            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[73]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[74]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[75]);
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop9;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[76]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[77]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[78]);
            	}

            // Amtscript.g:1482:2: ( (a1= 'for' (a2= IDENTIFIER ) ) )?
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==16) ) {
                alt10=1;
            }
            switch (alt10) {
                case 1 :
                    // Amtscript.g:1483:3: (a1= 'for' (a2= IDENTIFIER ) )
                    {
                    // Amtscript.g:1483:3: (a1= 'for' (a2= IDENTIFIER ) )
                    // Amtscript.g:1484:4: a1= 'for' (a2= IDENTIFIER )
                    {
                    a1=(Token)match(input,16,FOLLOW_16_in_parse_edu_pku_sei_AMT_Section1146); if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    				if (element == null) {
                    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    					startIncompleteElement(element);
                    				}
                    				collectHiddenTokens(element);
                    				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_1_0_0_0, null, true);
                    				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
                    			}

                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[79]);
                    			}

                    // Amtscript.g:1498:4: (a2= IDENTIFIER )
                    // Amtscript.g:1499:5: a2= IDENTIFIER
                    {
                    a2=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1172); if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    					if (terminateParsing) {
                    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    					}
                    					if (element == null) {
                    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    						startIncompleteElement(element);
                    					}
                    					if (a2 != null) {
                    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
                    						tokenResolver.setOptions(getOptions());
                    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
                    						tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODEL_NAME), result);
                    						Object resolvedObject = result.getResolvedToken();
                    						if (resolvedObject == null) {
                    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
                    						}
                    						java.lang.String resolved = (java.lang.String) resolvedObject;
                    						if (resolved != null) {
                    							Object value = resolved;
                    							element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__MODEL_NAME), value);
                    							completedElement(value, false);
                    						}
                    						collectHiddenTokens(element);
                    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_1_0_0_1, resolved, true);
                    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
                    					}
                    				}

                    }


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[80]);
                    			}

                    }


                    }
                    break;

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[81]);
            	}

            a3=(Token)match(input,20,FOLLOW_20_in_parse_edu_pku_sei_AMT_Section1218); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_2, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[82]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[83]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[84]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[85]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[86]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[87]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[88]);
            	}

            // Amtscript.g:1561:2: ( ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' ) )?
            int alt12=2;
            int LA12_0 = input.LA(1);

            if ( (LA12_0==IDENTIFIER) ) {
                int LA12_1 = input.LA(2);

                if ( (LA12_1==10||LA12_1==14) ) {
                    alt12=1;
                }
            }
            switch (alt12) {
                case 1 :
                    // Amtscript.g:1562:3: ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' )
                    {
                    // Amtscript.g:1562:3: ( (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';' )
                    // Amtscript.g:1563:4: (a4= IDENTIFIER ) ( (a5= ',' (a6= IDENTIFIER ) ) )* a7= ';'
                    {
                    // Amtscript.g:1563:4: (a4= IDENTIFIER )
                    // Amtscript.g:1564:5: a4= IDENTIFIER
                    {
                    a4=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1247); if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    					if (terminateParsing) {
                    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    					}
                    					if (element == null) {
                    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    						startIncompleteElement(element);
                    					}
                    					if (a4 != null) {
                    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
                    						tokenResolver.setOptions(getOptions());
                    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
                    						tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), result);
                    						Object resolvedObject = result.getResolvedToken();
                    						if (resolvedObject == null) {
                    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
                    						}
                    						String resolved = (String) resolvedObject;
                    						edu.pku.sei.AMT.Variable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
                    						collectHiddenTokens(element);
                    						registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.Section, edu.pku.sei.AMT.Variable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getSectionReferredVariablesReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), resolved, proxy);
                    						if (proxy != null) {
                    							Object value = proxy;
                    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES, value);
                    							completedElement(value, false);
                    						}
                    						collectHiddenTokens(element);
                    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_0, proxy, true);
                    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
                    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, proxy);
                    					}
                    				}

                    }


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[89]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[90]);
                    			}

                    // Amtscript.g:1604:4: ( (a5= ',' (a6= IDENTIFIER ) ) )*
                    loop11:
                    do {
                        int alt11=2;
                        int LA11_0 = input.LA(1);

                        if ( (LA11_0==10) ) {
                            alt11=1;
                        }


                        switch (alt11) {
                    	case 1 :
                    	    // Amtscript.g:1605:5: (a5= ',' (a6= IDENTIFIER ) )
                    	    {
                    	    // Amtscript.g:1605:5: (a5= ',' (a6= IDENTIFIER ) )
                    	    // Amtscript.g:1606:6: a5= ',' (a6= IDENTIFIER )
                    	    {
                    	    a5=(Token)match(input,10,FOLLOW_10_in_parse_edu_pku_sei_AMT_Section1293); if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    						if (element == null) {
                    	    							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    	    							startIncompleteElement(element);
                    	    						}
                    	    						collectHiddenTokens(element);
                    	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_1_0_0_0, null, true);
                    	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a5, element);
                    	    					}

                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[91]);
                    	    					}

                    	    // Amtscript.g:1620:6: (a6= IDENTIFIER )
                    	    // Amtscript.g:1621:7: a6= IDENTIFIER
                    	    {
                    	    a6=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1327); if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    							if (terminateParsing) {
                    	    								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    	    							}
                    	    							if (element == null) {
                    	    								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    	    								startIncompleteElement(element);
                    	    							}
                    	    							if (a6 != null) {
                    	    								edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
                    	    								tokenResolver.setOptions(getOptions());
                    	    								edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
                    	    								tokenResolver.resolve(a6.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), result);
                    	    								Object resolvedObject = result.getResolvedToken();
                    	    								if (resolvedObject == null) {
                    	    									addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a6).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a6).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a6).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a6).getStopIndex());
                    	    								}
                    	    								String resolved = (String) resolvedObject;
                    	    								edu.pku.sei.AMT.Variable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createPrimitiveVariable();
                    	    								collectHiddenTokens(element);
                    	    								registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.Section, edu.pku.sei.AMT.Variable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getSectionReferredVariablesReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES), resolved, proxy);
                    	    								if (proxy != null) {
                    	    									Object value = proxy;
                    	    									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__REFERRED_VARIABLES, value);
                    	    									completedElement(value, false);
                    	    								}
                    	    								collectHiddenTokens(element);
                    	    								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_1_0_0_1, proxy, true);
                    	    								copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a6, element);
                    	    								copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a6, proxy);
                    	    							}
                    	    						}

                    	    }


                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[92]);
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[93]);
                    	    					}

                    	    }


                    	    }
                    	    break;

                    	default :
                    	    break loop11;
                        }
                    } while (true);


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[94]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[95]);
                    			}

                    a7=(Token)match(input,14,FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1395); if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    				if (element == null) {
                    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    					startIncompleteElement(element);
                    				}
                    				collectHiddenTokens(element);
                    				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_3_0_0_2, null, true);
                    				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a7, element);
                    			}

                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[96]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[97]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[98]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[99]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[100]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[101]);
                    			}

                    }


                    }
                    break;

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[102]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[103]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[104]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[105]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[106]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[107]);
            	}

            // Amtscript.g:1700:2: ( ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' ) )?
            int alt14=2;
            int LA14_0 = input.LA(1);

            if ( (LA14_0==IDENTIFIER) ) {
                int LA14_1 = input.LA(2);

                if ( (LA14_1==11) ) {
                    alt14=1;
                }
            }
            switch (alt14) {
                case 1 :
                    // Amtscript.g:1701:3: ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' )
                    {
                    // Amtscript.g:1701:3: ( (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';' )
                    // Amtscript.g:1702:4: (a8_0= parse_edu_pku_sei_AMT_LinkConstraint ) ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )* a11= ';'
                    {
                    // Amtscript.g:1702:4: (a8_0= parse_edu_pku_sei_AMT_LinkConstraint )
                    // Amtscript.g:1703:5: a8_0= parse_edu_pku_sei_AMT_LinkConstraint
                    {
                    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_LinkConstraint_in_parse_edu_pku_sei_AMT_Section1443);
                    a8_0=parse_edu_pku_sei_AMT_LinkConstraint();

                    state._fsp--;
                    if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    					if (terminateParsing) {
                    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    					}
                    					if (element == null) {
                    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    						startIncompleteElement(element);
                    					}
                    					if (a8_0 != null) {
                    						if (a8_0 != null) {
                    							Object value = a8_0;
                    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__LINKS, value);
                    							completedElement(value, true);
                    						}
                    						collectHiddenTokens(element);
                    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_0, a8_0, true);
                    						copyLocalizationInfos(a8_0, element);
                    					}
                    				}

                    }


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[108]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[109]);
                    			}

                    // Amtscript.g:1729:4: ( (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) ) )*
                    loop13:
                    do {
                        int alt13=2;
                        int LA13_0 = input.LA(1);

                        if ( (LA13_0==10) ) {
                            alt13=1;
                        }


                        switch (alt13) {
                    	case 1 :
                    	    // Amtscript.g:1730:5: (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) )
                    	    {
                    	    // Amtscript.g:1730:5: (a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint ) )
                    	    // Amtscript.g:1731:6: a9= ',' (a10_0= parse_edu_pku_sei_AMT_LinkConstraint )
                    	    {
                    	    a9=(Token)match(input,10,FOLLOW_10_in_parse_edu_pku_sei_AMT_Section1484); if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    						if (element == null) {
                    	    							element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    	    							startIncompleteElement(element);
                    	    						}
                    	    						collectHiddenTokens(element);
                    	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_1_0_0_0, null, true);
                    	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a9, element);
                    	    					}

                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[110]);
                    	    					}

                    	    // Amtscript.g:1745:6: (a10_0= parse_edu_pku_sei_AMT_LinkConstraint )
                    	    // Amtscript.g:1746:7: a10_0= parse_edu_pku_sei_AMT_LinkConstraint
                    	    {
                    	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_LinkConstraint_in_parse_edu_pku_sei_AMT_Section1518);
                    	    a10_0=parse_edu_pku_sei_AMT_LinkConstraint();

                    	    state._fsp--;
                    	    if (state.failed) return element;

                    	    if ( state.backtracking==0 ) {
                    	    							if (terminateParsing) {
                    	    								throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
                    	    							}
                    	    							if (element == null) {
                    	    								element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    	    								startIncompleteElement(element);
                    	    							}
                    	    							if (a10_0 != null) {
                    	    								if (a10_0 != null) {
                    	    									Object value = a10_0;
                    	    									addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__LINKS, value);
                    	    									completedElement(value, true);
                    	    								}
                    	    								collectHiddenTokens(element);
                    	    								retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_1_0_0_1, a10_0, true);
                    	    								copyLocalizationInfos(a10_0, element);
                    	    							}
                    	    						}

                    	    }


                    	    if ( state.backtracking==0 ) {
                    	    						// expected elements (follow set)
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[111]);
                    	    						addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[112]);
                    	    					}

                    	    }


                    	    }
                    	    break;

                    	default :
                    	    break loop13;
                        }
                    } while (true);


                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[113]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[114]);
                    			}

                    a11=(Token)match(input,14,FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1579); if (state.failed) return element;

                    if ( state.backtracking==0 ) {
                    				if (element == null) {
                    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
                    					startIncompleteElement(element);
                    				}
                    				collectHiddenTokens(element);
                    				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_4_0_0_2, null, true);
                    				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a11, element);
                    			}

                    if ( state.backtracking==0 ) {
                    				// expected elements (follow set)
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[115]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[116]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[117]);
                    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[118]);
                    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[119]);
                    			}

                    }


                    }
                    break;

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[120]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[121]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[122]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[123]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[124]);
            	}

            // Amtscript.g:1809:2: ( ( (a12= EXPR ) a13= ';' ) )*
            loop15:
            do {
                int alt15=2;
                int LA15_0 = input.LA(1);

                if ( (LA15_0==EXPR) ) {
                    alt15=1;
                }


                switch (alt15) {
            	case 1 :
            	    // Amtscript.g:1810:3: ( (a12= EXPR ) a13= ';' )
            	    {
            	    // Amtscript.g:1810:3: ( (a12= EXPR ) a13= ';' )
            	    // Amtscript.g:1811:4: (a12= EXPR ) a13= ';'
            	    {
            	    // Amtscript.g:1811:4: (a12= EXPR )
            	    // Amtscript.g:1812:5: a12= EXPR
            	    {
            	    a12=(Token)match(input,EXPR,FOLLOW_EXPR_in_parse_edu_pku_sei_AMT_Section1627); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    					if (terminateParsing) {
            	    						throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    					}
            	    					if (element == null) {
            	    						element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            	    						startIncompleteElement(element);
            	    					}
            	    					if (a12 != null) {
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("EXPR");
            	    						tokenResolver.setOptions(getOptions());
            	    						edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            	    						tokenResolver.resolve(a12.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.SECTION__EXPRESSIONS), result);
            	    						Object resolvedObject = result.getResolvedToken();
            	    						if (resolvedObject == null) {
            	    							addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a12).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a12).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a12).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a12).getStopIndex());
            	    						}
            	    						java.lang.String resolved = (java.lang.String) resolvedObject;
            	    						if (resolved != null) {
            	    							Object value = resolved;
            	    							addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__EXPRESSIONS, value);
            	    							completedElement(value, false);
            	    						}
            	    						collectHiddenTokens(element);
            	    						retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_5_0_0_0, resolved, true);
            	    						copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a12, element);
            	    					}
            	    				}

            	    }


            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[125]);
            	    			}

            	    a13=(Token)match(input,14,FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1660); if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            	    					startIncompleteElement(element);
            	    				}
            	    				collectHiddenTokens(element);
            	    				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_5_0_0_1, null, true);
            	    				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a13, element);
            	    			}

            	    if ( state.backtracking==0 ) {
            	    				// expected elements (follow set)
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[126]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[127]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[128]);
            	    				addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[129]);
            	    				addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[130]);
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop15;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[131]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[132]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[133]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[134]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[135]);
            	}

            // Amtscript.g:1876:2: ( (a14_0= parse_edu_pku_sei_AMT_Section ) )*
            loop16:
            do {
                int alt16=2;
                int LA16_0 = input.LA(1);

                if ( (LA16_0==IDENTIFIER||LA16_0==16||LA16_0==20) ) {
                    alt16=1;
                }


                switch (alt16) {
            	case 1 :
            	    // Amtscript.g:1877:3: (a14_0= parse_edu_pku_sei_AMT_Section )
            	    {
            	    // Amtscript.g:1877:3: (a14_0= parse_edu_pku_sei_AMT_Section )
            	    // Amtscript.g:1878:4: a14_0= parse_edu_pku_sei_AMT_Section
            	    {
            	    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_Section_in_parse_edu_pku_sei_AMT_Section1702);
            	    a14_0=parse_edu_pku_sei_AMT_Section();

            	    state._fsp--;
            	    if (state.failed) return element;

            	    if ( state.backtracking==0 ) {
            	    				if (terminateParsing) {
            	    					throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            	    				}
            	    				if (element == null) {
            	    					element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            	    					startIncompleteElement(element);
            	    				}
            	    				if (a14_0 != null) {
            	    					if (a14_0 != null) {
            	    						Object value = a14_0;
            	    						addObjectToList(element, edu.pku.sei.AMT.AmtPackage.SECTION__SECTIONS, value);
            	    						completedElement(value, true);
            	    					}
            	    					collectHiddenTokens(element);
            	    					retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_6, a14_0, true);
            	    					copyLocalizationInfos(a14_0, element);
            	    				}
            	    			}

            	    }


            	    }
            	    break;

            	default :
            	    break loop16;
                }
            } while (true);


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[136]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[137]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getSection(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[138]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[139]);
            	}

            a15=(Token)match(input,21,FOLLOW_21_in_parse_edu_pku_sei_AMT_Section1728); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createSection();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_6_0_0_7, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a15, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[140]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[141]);
            		addExpectedElement(edu.pku.sei.AMT.AmtPackage.eINSTANCE.getRule(), edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[142]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[143]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[144]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 8, parse_edu_pku_sei_AMT_Section_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_Section"



    // $ANTLR start "parse_edu_pku_sei_AMT_LinkConstraint"
    // Amtscript.g:1927:1: parse_edu_pku_sei_AMT_LinkConstraint returns [edu.pku.sei.AMT.LinkConstraint element = null] : (a0= IDENTIFIER ) a1= '.' (a2= IDENTIFIER ) a3= '=' (a4= IDENTIFIER ) ;
    public final edu.pku.sei.AMT.LinkConstraint parse_edu_pku_sei_AMT_LinkConstraint() throws RecognitionException {
        edu.pku.sei.AMT.LinkConstraint element =  null;

        int parse_edu_pku_sei_AMT_LinkConstraint_StartIndex = input.index();

        Token a0=null;
        Token a1=null;
        Token a2=null;
        Token a3=null;
        Token a4=null;



        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 9) ) { return element; }

            // Amtscript.g:1930:2: ( (a0= IDENTIFIER ) a1= '.' (a2= IDENTIFIER ) a3= '=' (a4= IDENTIFIER ) )
            // Amtscript.g:1931:2: (a0= IDENTIFIER ) a1= '.' (a2= IDENTIFIER ) a3= '=' (a4= IDENTIFIER )
            {
            // Amtscript.g:1931:2: (a0= IDENTIFIER )
            // Amtscript.g:1932:3: a0= IDENTIFIER
            {
            a0=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1761); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
            				startIncompleteElement(element);
            			}
            			if (a0 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a0.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a0).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a0).getStopIndex());
            				}
            				String resolved = (String) resolvedObject;
            				edu.pku.sei.AMT.ObjectVariable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            				collectHiddenTokens(element);
            				registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.LinkConstraint, edu.pku.sei.AMT.ObjectVariable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getLinkConstraintSourceReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), resolved, proxy);
            				if (proxy != null) {
            					Object value = proxy;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__SOURCE), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_0, proxy, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, element);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a0, proxy);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[145]);
            	}

            a1=(Token)match(input,11,FOLLOW_11_in_parse_edu_pku_sei_AMT_LinkConstraint1782); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_1, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a1, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[146]);
            	}

            // Amtscript.g:1985:2: (a2= IDENTIFIER )
            // Amtscript.g:1986:3: a2= IDENTIFIER
            {
            a2=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1800); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
            				startIncompleteElement(element);
            			}
            			if (a2 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a2.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__REF_NAME), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a2).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a2).getStopIndex());
            				}
            				java.lang.String resolved = (java.lang.String) resolvedObject;
            				if (resolved != null) {
            					Object value = resolved;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__REF_NAME), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_2, resolved, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a2, element);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[147]);
            	}

            a3=(Token)match(input,15,FOLLOW_15_in_parse_edu_pku_sei_AMT_LinkConstraint1821); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            		if (element == null) {
            			element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
            			startIncompleteElement(element);
            		}
            		collectHiddenTokens(element);
            		retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_3, null, true);
            		copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken)a3, element);
            	}

            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[148]);
            	}

            // Amtscript.g:2035:2: (a4= IDENTIFIER )
            // Amtscript.g:2036:3: a4= IDENTIFIER
            {
            a4=(Token)match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1839); if (state.failed) return element;

            if ( state.backtracking==0 ) {
            			if (terminateParsing) {
            				throw new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptTerminateParsingException();
            			}
            			if (element == null) {
            				element = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createLinkConstraint();
            				startIncompleteElement(element);
            			}
            			if (a4 != null) {
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver("IDENTIFIER");
            				tokenResolver.setOptions(getOptions());
            				edu.pku.sei.AMT.resource.amtscript.IAmtscriptTokenResolveResult result = getFreshTokenResolveResult();
            				tokenResolver.resolve(a4.getText(), element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), result);
            				Object resolvedObject = result.getResolvedToken();
            				if (resolvedObject == null) {
            					addErrorToResource(result.getErrorMessage(), ((org.antlr.runtime3_4_0.CommonToken) a4).getLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getCharPositionInLine(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStartIndex(), ((org.antlr.runtime3_4_0.CommonToken) a4).getStopIndex());
            				}
            				String resolved = (String) resolvedObject;
            				edu.pku.sei.AMT.ObjectVariable proxy = edu.pku.sei.AMT.AmtFactory.eINSTANCE.createObjectVariable();
            				collectHiddenTokens(element);
            				registerContextDependentProxy(new edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptContextDependentURIFragmentFactory<edu.pku.sei.AMT.LinkConstraint, edu.pku.sei.AMT.ObjectVariable>(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getLinkConstraintTargetReferenceResolver()), element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), resolved, proxy);
            				if (proxy != null) {
            					Object value = proxy;
            					element.eSet(element.eClass().getEStructuralFeature(edu.pku.sei.AMT.AmtPackage.LINK_CONSTRAINT__TARGET), value);
            					completedElement(value, false);
            				}
            				collectHiddenTokens(element);
            				retrieveLayoutInformation(element, edu.pku.sei.AMT.resource.amtscript.grammar.AmtscriptGrammarInformationProvider.AMTSCRIPT_7_0_0_4, proxy, true);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, element);
            				copyLocalizationInfos((org.antlr.runtime3_4_0.CommonToken) a4, proxy);
            			}
            		}

            }


            if ( state.backtracking==0 ) {
            		// expected elements (follow set)
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[149]);
            		addExpectedElement(null, edu.pku.sei.AMT.resource.amtscript.mopp.AmtscriptExpectationConstants.EXPECTATIONS[150]);
            	}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 9, parse_edu_pku_sei_AMT_LinkConstraint_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_LinkConstraint"



    // $ANTLR start "parse_edu_pku_sei_AMT_Variable"
    // Amtscript.g:2078:1: parse_edu_pku_sei_AMT_Variable returns [edu.pku.sei.AMT.Variable element = null] : (c0= parse_edu_pku_sei_AMT_ObjectVariable |c1= parse_edu_pku_sei_AMT_PrimitiveVariable );
    public final edu.pku.sei.AMT.Variable parse_edu_pku_sei_AMT_Variable() throws RecognitionException {
        edu.pku.sei.AMT.Variable element =  null;

        int parse_edu_pku_sei_AMT_Variable_StartIndex = input.index();

        edu.pku.sei.AMT.ObjectVariable c0 =null;

        edu.pku.sei.AMT.PrimitiveVariable c1 =null;


        try {
            if ( state.backtracking>0 && alreadyParsedRule(input, 10) ) { return element; }

            // Amtscript.g:2079:2: (c0= parse_edu_pku_sei_AMT_ObjectVariable |c1= parse_edu_pku_sei_AMT_PrimitiveVariable )
            int alt17=2;
            int LA17_0 = input.LA(1);

            if ( (LA17_0==IDENTIFIER) ) {
                int LA17_1 = input.LA(2);

                if ( (LA17_1==12) ) {
                    int LA17_2 = input.LA(3);

                    if ( (LA17_2==IDENTIFIER) ) {
                        int LA17_3 = input.LA(4);

                        if ( (LA17_3==13) ) {
                            alt17=1;
                        }
                        else if ( (LA17_3==14) ) {
                            alt17=2;
                        }
                        else {
                            if (state.backtracking>0) {state.failed=true; return element;}
                            NoViableAltException nvae =
                                new NoViableAltException("", 17, 3, input);

                            throw nvae;

                        }
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return element;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 17, 2, input);

                        throw nvae;

                    }
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return element;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 17, 1, input);

                    throw nvae;

                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return element;}
                NoViableAltException nvae =
                    new NoViableAltException("", 17, 0, input);

                throw nvae;

            }
            switch (alt17) {
                case 1 :
                    // Amtscript.g:2080:2: c0= parse_edu_pku_sei_AMT_ObjectVariable
                    {
                    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_ObjectVariable_in_parse_edu_pku_sei_AMT_Variable1871);
                    c0=parse_edu_pku_sei_AMT_ObjectVariable();

                    state._fsp--;
                    if (state.failed) return element;

                    if ( state.backtracking==0 ) { element = c0; /* this is a subclass or primitive expression choice */ }

                    }
                    break;
                case 2 :
                    // Amtscript.g:2081:4: c1= parse_edu_pku_sei_AMT_PrimitiveVariable
                    {
                    pushFollow(FOLLOW_parse_edu_pku_sei_AMT_PrimitiveVariable_in_parse_edu_pku_sei_AMT_Variable1881);
                    c1=parse_edu_pku_sei_AMT_PrimitiveVariable();

                    state._fsp--;
                    if (state.failed) return element;

                    if ( state.backtracking==0 ) { element = c1; /* this is a subclass or primitive expression choice */ }

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
            if ( state.backtracking>0 ) { memoize(input, 10, parse_edu_pku_sei_AMT_Variable_StartIndex); }

        }
        return element;
    }
    // $ANTLR end "parse_edu_pku_sei_AMT_Variable"

    // Delegated rules


 

    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Transformation_in_start82 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_start89 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_19_in_parse_edu_pku_sei_AMT_Transformation115 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Transformation133 = new BitSet(new long[]{0x0000000000060022L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_TypedModel_in_parse_edu_pku_sei_AMT_Transformation169 = new BitSet(new long[]{0x0000000000060402L});
    public static final BitSet FOLLOW_10_in_parse_edu_pku_sei_AMT_Transformation210 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_TypedModel_in_parse_edu_pku_sei_AMT_Transformation244 = new BitSet(new long[]{0x0000000000060402L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Key_in_parse_edu_pku_sei_AMT_Transformation327 = new BitSet(new long[]{0x0000000000060002L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Rule_in_parse_edu_pku_sei_AMT_Transformation362 = new BitSet(new long[]{0x0000000000040002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_TypedModel407 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_parse_edu_pku_sei_AMT_TypedModel428 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_URI_in_parse_edu_pku_sei_AMT_TypedModel446 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_17_in_parse_edu_pku_sei_AMT_Key482 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Key500 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_parse_edu_pku_sei_AMT_Key521 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_KEYFEATURENAME_in_parse_edu_pku_sei_AMT_Key550 = new BitSet(new long[]{0x0000000000004040L});
    public static final BitSet FOLLOW_14_in_parse_edu_pku_sei_AMT_Key596 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_18_in_parse_edu_pku_sei_AMT_Rule625 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Rule654 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Rule704 = new BitSet(new long[]{0x0000000000100000L});
    public static final BitSet FOLLOW_20_in_parse_edu_pku_sei_AMT_Rule725 = new BitSet(new long[]{0x0000000000310020L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Variable_in_parse_edu_pku_sei_AMT_Rule754 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_parse_edu_pku_sei_AMT_Rule782 = new BitSet(new long[]{0x0000000000310020L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Section_in_parse_edu_pku_sei_AMT_Rule824 = new BitSet(new long[]{0x0000000000310020L});
    public static final BitSet FOLLOW_21_in_parse_edu_pku_sei_AMT_Rule850 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable883 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_parse_edu_pku_sei_AMT_ObjectVariable904 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable922 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_13_in_parse_edu_pku_sei_AMT_ObjectVariable943 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_ObjectVariable961 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_PrimitiveVariable1001 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_12_in_parse_edu_pku_sei_AMT_PrimitiveVariable1022 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_PrimitiveVariable1040 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1091 = new BitSet(new long[]{0x0000000000110020L});
    public static final BitSet FOLLOW_16_in_parse_edu_pku_sei_AMT_Section1146 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1172 = new BitSet(new long[]{0x0000000000100000L});
    public static final BitSet FOLLOW_20_in_parse_edu_pku_sei_AMT_Section1218 = new BitSet(new long[]{0x0000000000310030L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1247 = new BitSet(new long[]{0x0000000000004400L});
    public static final BitSet FOLLOW_10_in_parse_edu_pku_sei_AMT_Section1293 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_Section1327 = new BitSet(new long[]{0x0000000000004400L});
    public static final BitSet FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1395 = new BitSet(new long[]{0x0000000000310030L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_LinkConstraint_in_parse_edu_pku_sei_AMT_Section1443 = new BitSet(new long[]{0x0000000000004400L});
    public static final BitSet FOLLOW_10_in_parse_edu_pku_sei_AMT_Section1484 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_LinkConstraint_in_parse_edu_pku_sei_AMT_Section1518 = new BitSet(new long[]{0x0000000000004400L});
    public static final BitSet FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1579 = new BitSet(new long[]{0x0000000000310030L});
    public static final BitSet FOLLOW_EXPR_in_parse_edu_pku_sei_AMT_Section1627 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_14_in_parse_edu_pku_sei_AMT_Section1660 = new BitSet(new long[]{0x0000000000310030L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_Section_in_parse_edu_pku_sei_AMT_Section1702 = new BitSet(new long[]{0x0000000000310020L});
    public static final BitSet FOLLOW_21_in_parse_edu_pku_sei_AMT_Section1728 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1761 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_11_in_parse_edu_pku_sei_AMT_LinkConstraint1782 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1800 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_15_in_parse_edu_pku_sei_AMT_LinkConstraint1821 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_IDENTIFIER_in_parse_edu_pku_sei_AMT_LinkConstraint1839 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_ObjectVariable_in_parse_edu_pku_sei_AMT_Variable1871 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_parse_edu_pku_sei_AMT_PrimitiveVariable_in_parse_edu_pku_sei_AMT_Variable1881 = new BitSet(new long[]{0x0000000000000002L});

}